home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 1995-08-02 | 8.9 KB | 220 lines | [ TEXT/ToyS]
----------------------------------------------------------------------- -- StarNine Technologies, Inc., hereby disclaims all copyright interest -- in the following source code written by Joshua D. Baer -- based on cgi shell by Jon Wiederspan (jonwd@tjp.washington.edu). -- -- This source code is free and has been placed into the public domain. -- You can redistribute it, modify it (including these comments) and/or -- create derivative works from it as you see fit. -- -- This source code is made available in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ----------------------------------------------------------------------- --STUFF YOU WOULD WANT TO CUSTOMIZE (until the "END OF CUSTOMIZABLE STUFF" line) -- --this is the file specification of the backround file to use property background : "<BODY BACKGROUND=background.gif>" --these contain information about the adminstrator for the footers of HTML pages generated property adminname : "Administrator Name" property adminaddress : "adminstrator@yourserver.yourdomain" property adminurl : "yourhomepage" property background : "<BODY BACKGROUND=background.gif>" (* ** This routine checks the listname value passed from the HTML ** form and returns the respective servicename. This is necessary ** in order to uniquely qualify the address list passed to ** ListSTAR. ** ** When editing, the values on the left (in the ** if...then part) are the checkbox names in the HTML form. The ** values on the right (after the set...to part) are the names of ** the service associated with each list. Make sure both of these ** names are spelled exactly. After this is done scroll down to Comment B: ** which will instruct you to input your Address List Name. *) on s9setservice(listname) if listname is "Test List 1" then set listname to "Test 1 Service Name" if listname is "Test List 2" then set listname to "Test 2 Service Name" if listname is "Test List 3" then set listname to "Test 3 Service Name" if listname is "Test List 4" then set listname to "Test 4 Service Name" return listname end s9setservice (* ** This just returns the footer applied to the bottom of all HTML ** documents. Customize it at will, just be sure to end it with ** "</BODY></HTML>". *) on s9footer() return "<HR SIZE=2>" & ¬ "<H4>Return to the <A HREF=liststar-admin.html>ListSTAR Administration form</A></H4><HR SIZE=4>" & ¬ (current date) & "<BR><A HREF=" & adminurl & ">" & adminname & ¬ "</A><BR><A HREF=mailto:" & adminaddress & "><ADDRESS>" & ¬ adminaddress & "</ADDRESS></A></BODY></HTML>" end s9footer --END OF CUSTOMIZABLE STUFF property crlf : (ASCII character 13) & (ASCII character 10) property http_10_header : "HTTP/1.0 200 OK" & crlf & "Server: WebSTAR/1.0 ID/ACGI" & crlf & ¬ "MIME-Version: 1.0" & crlf & "Content-type: text/html" & crlf & crlf property idletime : 1800 property datestamp : 0 property AlreadyInList : 107 property NotInList : 105 set datestamp to current date on s9error105(thename, thelist) return "<H4>Sorry, " & thename & " is not a subscriber of the " & thelist & ".</H4>" end s9error105 on s9error107(thename, thelist) return "<H4>Sorry, " & thename & " is already a subscriber of the " & thelist & ".</H4>" end s9error107 on s9subcheck(return_page, thename, theaddress, listaction, thelists) repeat with thelist in thelists set return_page to return_page & thename & " <I>(" & theaddress & ")</I> is " set servicename to s9setservice(thelist) tell application "ListSTAR Server" if ((StarNine Is thelist Service servicename addresses {FreeFormName:thename, EMailAddress:theaddress} as StarNineAddress) is 0) then set return_page to return_page & "<B>not</B> " end if end tell set return_page to return_page & "a member of the " & thelist & ".<P>" & return end repeat return return_page end s9subcheck on s9subscribe(return_page, thename, theaddress, listaction, thelists) repeat with thelist in thelists set servicename to s9setservice(thelist) try tell application "ListSTAR Server" to StarNine Subscribe thelist Service servicename addresses {FreeFormName:thename, EMailAddress:theaddress} as StarNineAddress set return_page to return_page & thename & " <I>(" & theaddress & ")</I> has been <B>subscribed</B> to the " & thelist & ".<P>" & return on error errMsg number errNum if errNum is AlreadyInList then set return_page to return_page & s9error107(thename, thelist) else error errMsg number errNum end if end try end repeat return return_page end s9subscribe on s9unsubscribe(return_page, thename, theaddress, listaction, thelists) repeat with thelist in thelists set servicename to s9setservice(thelist) try tell application "ListSTAR Server" to StarNine Unsubscribe thelist Service servicename addresses {FreeFormName:thename, EMailAddress:theaddress} as StarNineAddress set return_page to return_page & thename & " <I>(" & theaddress & ")</I> has been <B>unsubscribed</B> from the " & thelist & ".<P>" & return on error errMsg number errNum if errNum is NotInList then set return_page to return_page & s9error105(thename, thelist) else error errMsg number errNum end if end try end repeat return return_page end s9unsubscribe on «event WWWΩsdoc» path_args ¬ given «class kfor»:http_search_args, «class post»:post_args, «class meth»:method, «class addr»:client_address, «class user»:username, «class pass»:password, «class frmu»:from_user, «class svnm»:server_name, «class svpt»:server_port, «class scnm»:script_name, «class ctyp»:content_type, «class refr»:referer, «class Agnt»:user_agent, «class Kact»:action, «class Kapt»:action_path, «class Kcip»:client_ip, «class Kfrq»:full_request try set thelists to {} set datestamp to current date set return_page to http_10_header & "<HTML><HEAD><TITLE>ListSTAR Admin Results</TITLE></HEAD>" & background & "<BODY><H1>ListSTAR Admin Results</H1>" & return & return set postarglist to tokenize (dePlus post_args) with delimiters {"&"} set oldDelim to AppleScript's text item delimiters set AppleScript's text item delimiters to {"="} --the quoted part of each "if...then" statement should contain the "name" of a field in the referring form. repeat with currpostarg in postarglist set currname to first text item of currpostarg if currname = "name" then set myname to (Decode URL (last text item of currpostarg)) else if currname = "address" then set useraddress to (Decode URL (last text item of currpostarg)) else if currname = "listAction" then set listaction to (Decode URL (last text item of currpostarg)) --COMMENT B: modify the following to accomodate the number of lists --all you need to do is copy the first two lines, and change the quoted --statement to the list name else if currname = "Test List 1" then set thelists to thelists & {currname} else if currname = "Test List 2" then set thelists to thelists & {currname} else if currname = "Test List 3" then set thelists to thelists & {currname} else if currname = "Test List 4" then set thelists to thelists & {currname} else if currname = "S" then -- ignore it. That's the Submit button. else error ("Unknown variable in post_args: " & currname) number 100 end if end repeat set AppleScript's text item delimiters to oldDelim if thelists is {} then set return_page to return_page & "<H3>No address lists were selected. Please try again.</H3>" & return else if useraddress is "" then set return_page to return_page & "<H3>You must fill in an email address Please try again.</H3>" & return else if listaction is "Subscribe Check" then set return_page to s9subcheck(return_page, myname, useraddress, listaction, thelists) else if listaction is "Subscribe" then set return_page to s9subscribe(return_page, myname, useraddress, listaction, thelists) else if listaction is "Unsubscribe" then set return_page to s9unsubscribe(return_page, myname, useraddress, listaction, thelists) else set return_page to return_page & "An unknown action was requested: " & listaction & "<BR>" & return end if set return_page to return_page & s9footer() return return_page on error errMsg number errNum set return_page to http_10_header ¬ & "<HTML><HEAD><TITLE>Error Page</TITLE></HEAD>" & "<BODY><H1>Error Encountered!</H1>" & return ¬ & "An error was encountered while trying to run this script." & return set return_page to return_page ¬ & "<H3>Error Message</H3>" & return & errMsg & return ¬ & "<H3>Error Number</H3>" & return & errNum & return ¬ & "<H3>Date</H3>" & return & (current date) & return set return_page to return_page ¬ & "<HR>Please notify " & adminname & "at " & ¬ "<A HREF=\"mailto:" & adminaddress & "\">" & adminaddress & "</A>" & " of this error." & "</BODY></HTML>" return return_page end try end «event WWWΩsdoc» on idle if (current date) > (datestamp + idletime) then quit end if return 5 end idle on quit continue quit end quit